<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>036-generator函数的next方法参数.html</title>
</head>
<body>
	
</body>
<script type="text/javascript">
	function * gen(x){
		console.log('start gen x=',x)
		const y = yield(x + 10)
		console.log('y=',y)
		const z = yield(y + 20)
		console.log('z=',z)
		return (x+y+z)
	}
	const g = gen(5)

	//next 参数代表上一个yield的返回值

	// console.log(g.next())
	// console.log(g.next())
	// console.log(g.next())


	// const data1 = g.next()
	// console.log(data1)
	// const data2 = g.next(data1.value)
	// console.log(data2)
	// const data3 = g.next(data2.value)
	// console.log(data3)

	//
	console.log(g.next(20))
	console.log(g.next(30))
	console.log(g.next(80))
</script>
</html>